package interfaces.impl;

import interfaces.ActionInterface;
import interfaces.AgentInterface;
import interfaces.WorldInterface;

import java.awt.Graphics;
import java.util.ArrayList;



import objects.SpetialFeature;
import objects.WorldObject;
import universe.Universe;

public abstract class Agent implements AgentInterface {
	
	protected int id;
	protected String name;
	
	protected ArrayList<ActionInterface> listActions;
	protected int priority;

	
	public ArrayList<ActionInterface> getActionsList(){
		return listActions;
	}
	
	public void getActionsList(ArrayList<ActionInterface> actionList){
		this.listActions=actionList;
	}

	public abstract void update(WorldObject object, Universe worldI, double time);
	
	public abstract void paint(Graphics g, WorldObject object);

	public int getID() {
		return id;
	}

	public void setID(int id) {
		this.id = id;
	}
	
	public abstract String getName();
	
	public abstract void setName(String name);
	
	public boolean canUpdate(WorldObject object){
		boolean found;
		ArrayList<ActionInterface> list=new ArrayList<ActionInterface>();
		for(ActionInterface i : listActions){
			found=false;
			for(ActionInterface j : object.getListActions()){
				if(i.getId()==j.getId()){
					//j.setValue(i.getValue());
					//i=j;
					list.add(j);
					found=true;
					break;
				}
			}
			if(!found){
				return false;
			}
		}
		listActions=list;
		return true;
	}

	public ArrayList<ActionInterface> getListActions() {
		return listActions;
	}

	public void setListActions(ArrayList<ActionInterface> listActions) {
		this.listActions = listActions;
	}

	public int getPriority() {
		return priority;
	}

	public void setPriority(int priority) {
		this.priority = priority;
	}
	
	
	
}
